package com.dyc;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {

    @ViewInject(R.id.button)
    private Button button;

    @ViewInject(R.id.button2)
    private Button button2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
    }

    @Event(value = {R.id.button}, type = View.OnClickListener.class)
    private void Click(View view) {
        Toast.makeText(MainActivity.this, "click", Toast.LENGTH_SHORT).show();
    }

    @Event(value = {R.id.button, R.id.button2}, type = View.OnLongClickListener.class)
    private boolean LongClick(View view) {
        switch (view.getId()) {
            case R.id.button:
                Toast.makeText(MainActivity.this, "Long Click1", Toast.LENGTH_SHORT).show();
                break;
            case R.id.button2:
                Toast.makeText(MainActivity.this, "Long Click2", Toast.LENGTH_SHORT).show();
                break;
        }
        return true;
    }

}
